package com.ilovepostcard;

import com.ilovepostcard.utils.NetWorkUtil;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;

public class ShareNoNetworkActivity extends BaseActivity implements OnClickListener{

	Button setting;
	@Override
    public void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_share_nonetwork);
		init();
	}
	
	private void init()
	{
		setting = (Button)findViewById(R.id.network_setting);
		setting.setOnClickListener(this);
	}

	public void onBackPressed () 
	{
		Intent intent = new Intent(this,MainActivity.class);
		intent.putExtra("noresume", "no");
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivity(intent);
		
	}
	@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
		if(0xff == requestCode)
		{
			final ProgressDialog processDlg = new ProgressDialog( this );
            processDlg.setMessage(getResources().getString(R.string.loading));
            processDlg.setIndeterminate( true );
            processDlg.setCancelable( false );
            processDlg.show();
            Handler h = new Handler();
            h.postDelayed(new Runnable()
            {

				@Override
				public void run() {
					processDlg.dismiss();
					/*if(NetWorkUtil.isNetworkAvailable(ShareNoNetworkActivity.this))
					{
						
						Toast.makeText(ShareNoNetworkActivity.this, "网络可用了，你可以继续上传明信片了!", Toast.LENGTH_SHORT).show();
						finish();
						
					}
					else
					{
						Intent intent = new Intent(ShareNoNetworkActivity.this,MainActivity.class);
						intent.putExtra("noresume", "no");
						intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
						startActivity(intent);
					}*/
					finish();
					
				}
            
            }, 8000);
			
		}

	}
	
	@Override
	public void onClick(View v) {


		if(v.getId() == R.id.network_setting)
		{
			startActivityForResult(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS), 0xff);
		}
		
	}
	
}
